#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <assert.h>
using std::cout;
using std::cin;
using std::endl;

class Date
{
public:
	//void Init(Data* const this, int year, int month, int day)
	void Init(int year, int month, int day)
	{
		_year = year;
		_month = month;
		_day = day;
		//this->_year = year;
		//this->_month = month;
		//this->_day = day;
	}
	void print()
	{
		cout << _year << "/" << _month << "/" << _day << endl;
	}

private:
	int _year;
	int _month;
	int _day;
};
int main()
{
	Date day1;
	Date day2;
	day1.Init(2024, 5, 20);
	day1.print();
	return 0;
}



#include<iostream>
using namespace std;
class A
{
public:
	void Print()
	{
		cout << "A::Print()" << endl;
		cout << _a << endl;
	}
private:
	int _a;
};
int main()
{
	A* p = nullptr;
	p->Print();
	return 0;
}


class Stack
{
public:
	void Init(int capacity = 4);
	void Push(int x);
	void Pop();
	int Top();
	int Empty();
	void Destry()
	{
		assert(_next);
		if (_next)
			free(_next);
		_next = NULL;
		_top = 0;
		_capacity = 0;
	}
private:
	int _top;
	int _capacity;
	int* _next;
};


void Stack::Init(int capacity)
{
	_next = (int*)malloc(sizeof(int) * capacity);
	_top = 0;
	_capacity = capacity;
}
void Stack::Push(int x)
{
	if (_top == _capacity)
	{
		int newcapacity = _capacity == 0 ? 4 : _capacity * 2;
		int* newNext = (int*)realloc(_next, sizeof(int) * newcapacity);
		if (newNext == NULL)
		{
			perror("realloc fail");
			exit(1);
		}
		_next = newNext;
		_capacity = newcapacity;
	}
	_next[_top++] = x;
}

void Stack::Pop()
{
	assert(_next && _top > 0);
	_top--;
}
int Stack::Top()
{
	assert(_next && _top > 0);
	return _next[_top - 1];
}
int Stack::Empty()
{
	return _top == 0;
}

//int main()
//{
//	Stack s1;
//	s1.Init();
//
//	s1.Push(1);
//	s1.Push(2);
//	s1.Push(3);
//	s1.Push(4);
//
//	while (!s1.Empty())
//	{
//		cout << s1.Top() << endl;
//		s1.Pop();
//	}
//	s1.Destry();
//	return 0;
//}